MONGOD = $(shell which mongod)
MONGOD_CONF = /etc/mongod.conf

mongodb.out: $(HOME)/mongo/mongod.version
	touch $@
	



/etc/yum.repos.d/mongodb-org.repo:
	rm -rf $@
	echo "[mongodb-org-3.4]" >> $@
	echo "name=MongoDB Repository" >> $@
	echo "baseurl=https://repo.mongodb.org/yum/redhat/"'$$'"releasever/mongodb-org/3.4/x86_64/" >> $@
	echo "gpgcheck=1" >> $@
	echo "enabled=1" >> $@
	echo "gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc" >> $@



$(HOME)/mongo/mongod.version: /etc/yum.repos.d/mongodb-org.repo
	yum repolist
	yum -y install mongodb-org
	systemctl start mongod
	systemctl enable mongod
	systemctl status mongod
	systemctl stop mongod
	cp -af /var/lib/mongo $(HOME)/
	mv /var/lib/mongo /var/lib/mongo~
	ln -s $(HOME)/mongo /var/lib/mongo
	systemctl start mongod	
	mongod -version > $@

